package com.qiantu.phone.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.qiantu.api.entity.UniversalDeviceAction;
import com.qiantu.api.entity.UniversalDeviceData;
import com.qiantu.phone.R;
import com.qiantu.phone.app.AppAdapter;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class UniversalConfigAdapter extends AppAdapter<List<UniversalDeviceData>>{
    public UniversalConfigAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public UniversalConfigAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new UniversalConfigAdapter.ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView tvFloorName;
        private final RecyclerView roomRecyclerView;
        private UniversalConfigActionAdapter roomLabelAdapter;

        private ViewHolder() {
            super(R.layout.room_floor_select_item);
            tvFloorName = findViewById(R.id.tv_floor_name);
            roomRecyclerView = findViewById(R.id.room_recycler_view);
            roomRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

        }

        @Override
        public void onBindView(int position) {
            List<UniversalDeviceData> actionDtos = getItem(position);
            UniversalDeviceData actionDto = actionDtos.get(0);
            tvFloorName.setText(actionDto.getActionName());
            roomLabelAdapter = new UniversalConfigActionAdapter(actionDtos);
            roomRecyclerView.setAdapter(roomLabelAdapter);
        }
    }
}
